package oopwork;

class Draw{
    private int high;
    public Draw(int high){
        if (high>3) this.high = high;
        else {
            System.out.println("输入高度错误，高度至少为3");
            this.high=0;
        };
    }
    public int getHigh() {
        return high;
    }

    public void setHigh(int high) {
        this.high = high;
    }

    public void DrawRectangle(){
        String pen="*";
        for (int i = 0; i < high; i++) {
            pen=pen + "  *";
        }
        for (int j = 0; j <high; j++) {
            System.out.println(pen);
        }
    }

    public  void  DrawSquare(){
        String pen ="*";
        for (int i = 1; i <high ; i++) {
            pen = pen +"  *";
        }
        for (int i = 0; i < high; i++) {
            System.out.println(pen);
        }
    }
    public void DrawTriangle(){
        String pen ="*";
        System.out.println(pen);
        for (int i = 0; i < high; i++) {
            pen =pen +"  *";
            System.out.println(pen);
        }
    }
    public void DrawParallelogram(){
        String pen ="*";
        String space ="";
        for (int i = 0; i < high; i++) {
            pen = pen + "  *";
        }
        for (int i = 0; i < high; i++) {
            space = space+"  ";
            System.out.println(space+pen);
        }
    }
}
public class MyDraw {
    public static void main(String[] args) {
        Draw dr1=new Draw(5);
        dr1.DrawRectangle();
        System.out.println(" ");
        dr1.DrawSquare();
        System.out.println(" ");
        dr1.DrawTriangle();
        System.out.println(" ");
        dr1.DrawParallelogram();
    }
}
